package com.zhou.message.dto;

import com.zhou.util.FileUtil;
import com.zhou.framework.util.EnumClassUtil;
import com.zhou.message.common.AttachSourceEnum;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
public class AttachmentDto implements Serializable {
    private Integer id;
    /**
     * 用户id
     */
    private Integer userId;

    /**
     * 文件名
     */
    private String fileName;
    private String realName;
    private String username;

    /**
     * 文件后缀
     */
    private String prefix;

    /**
     * 文件类型；1-头像；2-文件
     */
    private Integer type;

    private String description;

    private Long size;

    private String fileSize;

    /**
     * 来源id
     */
    private Integer sourceId;

    /**
     * 附件来源
     */
    private String source;

    private String sourceName;

    private Date createDt;

    private Integer isPub;

    private String md5;

    private Date updateDt;

    public void setSize(Long size) {
        this.size = size;
        this.fileSize = FileUtil.sizeToChinese(size);
    }

    public void setSource(String source) {
        this.source = source;
        this.sourceName = EnumClassUtil.getName(AttachSourceEnum.class,source,"其他");
    }
}
